package com.aaa.entity;

import java.util.List;

public class Pager {
    /**
     * 当前页码：传参
     */
    private Integer pageNo;
    /**
     * 每页条数：传参
     */
    private Integer pageSize;
    /**
     * 首页
     */
    private Integer first;
    /**
     * 下页
     */
    private Integer next;
    /**
     * 前页码
     */
    private Integer prev;
    /**
     * 尾页
     */
    private Integer last;

    /**
     * 总页数
     */
    private Integer pages;

    private List data;

    private Integer totalCount;

    public Integer getPageNo() {
        return pageNo;
    }

    public void setPageNo(Integer pageNo) {
        this.pageNo = pageNo;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getFirst() {
        return first;
    }

    public void setFirst(Integer first) {
        this.first = first;
    }

    public Integer getNext() {
        return next;
    }

    public void setNext(Integer next) {
        this.next = next;
    }

    public Integer getPrev() {
        return prev;
    }

    public void setPrev(Integer prev) {
        this.prev = prev;
    }

    public Integer getLast() {
        return last;
    }

    public void setLast(Integer last) {
        this.last = last;
    }

    public Integer getPages() {
        return pages;
    }

    public void setPages(Integer pages) {
        this.pages = pages;
    }

    public List getData() {
        return data;
    }

    public void setData(List data) {
        this.data = data;
    }

    public Integer getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(Integer totalCount) {
        this.totalCount = totalCount;
    }

    public Pager(Integer pageNo, Integer pageSize, List data, Integer totalCount) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        this.data = data;
        this.totalCount = totalCount;
        //页数
        this.pages=totalCount%pageSize==0?totalCount/pageSize:totalCount/pageSize+1;
        //页号
        if(pageNo<0) this.pageNo=1;
        //上一页
        if (pageNo>1) {
            this.prev = pageNo - 1;
        }else {
            this.prev=1;
        }

        //下一页
        if (pageNo<pages)
        {
            this.next=pageNo+1;
        }
        else {
            this.next=1;
        }
        //尾页
        this.last=pages;

    }
}
